<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>商品库存记录</h1>
<table border="1" id="t_p">
    <caption>商品库存列单</caption>
    <tr>
        <th>库存编号</th>
        <th>商品名称</th>
        <th>商品价格</th>
        <th>商品库存量</th>
        <th>商品处理</th>
    </tr>
    <tr v-for="p in arr">
        <td>{{p.id}}</td>
        <td>{{p.title}}</td>
        <td>{{p.price}}</td>
        <td>{{p.saleCount}}</td>
        <td>
            <a href="javascript: void(0)" @click="del(p.id)">删除</a>
            <a :href="'/update.html?id='+p.id">修改</a>
        </td>
    </tr>
</table>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"#t_p",
        data:{
            arr:[{id:"",title:"",price:"",saleCount:""}]
        },
        created:function (){
            axios.get("/select").then(function (response) {
                v.arr = response.data;
            })
        },
        methods:{
            del(id){
                axios.get("/delete?id="+id).then(function (response){
                    alert("删除成功!");
                    location.reload();
                })
            }
        }
    })
</script>
</body>
</html>